package org.jluzhCS.mylogin.action;

import org.jluzhCS.mylogin.domain.User;

import com.sun.javafx.collections.MappingChange.Map;

import ognl.DefaultTypeConverter;

public class UserConverter extends DefaultTypeConverter
{
	public Object convertValue(Map context, Object value, Class toType)
	{
		if(toType == User.class)
		{
			String[] params = (String[])value;
			User user = new User();
			String[] userValues = params[0].split(",");
			user.setName(userValues[0]);
			user.setPassword(userValues[1]);
			return user;
		}
		else if(toType == String.class)
		{
			User user = (User)value;
			return "<" + user.getName() + "," +
					user.getPassword() + "," ;
		}
		return null;
	}
}
